Ext.define('PJ.view.messagenotification.Frame', {
    extend: 'Ext.container.Container',
    requires: ['PJ.view.messagenotification.NewsList','PJ.view.messagenotification.RemindList'],
    alias: ['widget.messagenotificationFrame'],
    layout: 'form',
    // 必须增加这段，强制提前加载类，这样才可以使用简写
    initComponent: function(){
    	var me = this;
        this.items = [{
        	xtype: 'container',
        	layout: 'column',
        	items: [{
        		xtype: 'container',
        		layout: 'column',
        		columnWidth: .1,
        		items: [{
    	    		 xtype: 'button',
    	    		 text: '刷新',
    	             iconCls: 'refurbishIco',
    	             itemId: this.oldId + "Refurbish",
    	             disabled: false,
    	             width: 60,
    	             handler: function(){
    	            	 var newsList = me.down("newsList");
    	            	 var store = newsList.store;
    	                 var params = store.proxy.extraParams;
    	                 var newParams = {
    	                 		limit: 5
    	                 };
    	                 Ext.apply(params, newParams);
    	                 store.isLoad = true;
    	                 store.load(function(rec, operation, success){
    	                 	if(rec.length == 0){
    	                 		newsList.flag = "zw";
    	                 		var model = Ext.create("PJ.model.messagemanagement.ReceiveMessagesList");
    	                 		model.set({
    	                 			"newsTitle": "暂无通知"
    	                 		});
    	                 		rec.push(model);
    	                 		model.commit();//提交model，如果添加此句则列表上不会再显示左上角修改后的标识符
    	                 		store.add(rec)
    	                 	}
    	                 });
    	            	 var remindList = me.down("remindList");
    	            	 var store1 = remindList.store;
    	                 var params = store1.proxy.extraParams;
    	                 var newParams = {
    	                 		limit: 5
    	                 };
    	                 Ext.apply(params, newParams);
    	                 store1.isLoad = true;
    	                 store1.load(function(rec, operation, success){
    	                 	if(rec.length == 0){
    	                 		remindList.flag = "zw";
    	                 		var model = Ext.create("PJ.model.remindmanagement.List");
    	                 		model.set({
    	                 			"remindValue": "暂无提醒"
    	                 		});
    	                 		rec.push(model);
    	                 		model.commit();//提交model，如果添加此句则列表上不会再显示左上角修改后的标识符
    	                 		store1.add(rec)
    	                 	}
    	                 });
    	             }
    	    	}]
        	},{
            	xtype:"label",
            	columnWidth: .9,
            	html:"<div id='newRemind' style='font-size:15px;text-align:right;width:100%;'>未读通知条&nbsp&nbsp&nbsp&nbsp&nbsp</div>"
//        		html:"<div id='newRemind' style='font-size:15px;text-align:right;width:100%;'>未读提醒条，未读通知条&nbsp&nbsp&nbsp&nbsp&nbsp</div>"
            }]
        },{
        	xtype: 'newsList',
        	height:300
        },{
        	xtype: 'remindList'
        }];
        this.callParent(arguments);
    },
    listeners: {
    	afterrender: function(){
            Ext.Ajax.request({
    			url: showMsgUrl,
                success: function(response){
                    var data = response.responseText;
                    var json = Ext.decode(data, true);
                    var newsUserNoReadCount = json.data.newsUserNoReadCount;
                    var remindUserNoReadCount = json.data.remindUserNoReadCount;
                    $("#newRemind")[0].innerHTML="您有"+newsUserNoReadCount+"条未读通知,"+remindUserNoReadCount+"条未读提醒";
                }
            });
        }/*,
        beforerender: function(){
        	var me=this;
            var store = me.down('newsList').getStore();
            // grid加载生效
            store.isLoad = true;
            store.load(function(rec, operation, success){
				if(rec.length == 0){
					var model = Ext.create("PJ.model.messagemanagement.ReceiveMessagesList");
					model.set({
						"newsTitle": "暂无通知"
					});
					rec.push(model);
					model.commit();//提交model，如果添加此句则列表上不会再显示左上角修改后的标识符
					store.add(rec)
				}
			});
            var store = me.down('remindList').getStore();
            // grid加载生效
            store.isLoad = true;
            store.load(function(rec, operation, success){
				if(rec.length == 0){
					var model = Ext.create("PJ.model.remindmanagement.List");
					model.set({
						"newsTitle": "暂无提醒"
					});
					rec.push(model);
					model.commit();//提交model，如果添加此句则列表上不会再显示左上角修改后的标识符
					store.add(rec)
				}
			});
        }*/
    }
});
